j3deditor.bin.editor.util
Class VertexManipulator

java.lang.Object
  extended by j3deditor.bin.editor.util.VertexManipulator

public class VertexManipulator
extends java.lang.Object

Utility for converting coordinates between 3D scene and Scene2D.

Author:
Risto Seene

Constructor Summary
VertexManipulator()
           
 
Method Summary
static boolean addVertex(J3DePoint2D location, Scene2D scene)
          Adds a new vertex to the specified polygonal mesh if possible.
static int getEdgeEndIndex(int vertexIndex, Scene2D scene)
          Returns the index of the second vertex of the edge with the specified first vertex.
static int getStateType(Scene2D scene)
          Returns the manipulation target of the specified scene: Vertex.TEXTURE_VERTEX_STATE or Vertex.COORDINATE_VERTEX_STATE.
static J3DePoint2D getVertexPosition2D(Vertex v, Scene2D scene)
          Returns the position of a vertex in the coordinate system of the specified Scene2D.
static boolean isInBounds(J3DePoint2D pos, J3DePoint2D p1, J3DePoint2D p2)
          Returns true if the specified point is located inside the specified rectangle.
static void rotateVertices(float rotation, Scene2D scene)
          Rotates the selected part of a polygonal mesh.
static void scaleVertices(float scaleChange, Scene2D scene)
          Resizes the selected part of a polygonal mesh.
static void selectVertex(J3DePoint2D p, Scene2D scene, boolean isShiftDown)
          Selects a vertex which is close enough to cursor.
static void selectVertices(J3DePoint2D p1, J3DePoint2D p2, Scene2D scene)
          Selects all vertices which are located inside the specified rectangle.
static void translateVertices(float x, float y, Scene2D scene)
          Translates the selected vertices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VertexManipulator

public VertexManipulator()
Method Detail

getStateType

public static int getStateType(Scene2D scene)
Returns the manipulation target of the specified scene: Vertex.TEXTURE_VERTEX_STATE or Vertex.COORDINATE_VERTEX_STATE.

Parameters:
scene - Scene2D which manipulation target will be returned
Returns:
Vertex.TEXTURE_VERTEX_STATE or Vertex.COORDINATE_VERTEX_STATE

selectVertex

public static void selectVertex(J3DePoint2D p,
                                Scene2D scene,
                                boolean isShiftDown)
Selects a vertex which is close enough to cursor.

Parameters:
p - the position of cursor
scene - Scene2D the selection was made in
isShiftDown - is user holding shift key or not.
if true more vertices can be selected by each selection,
otherwise all selected vertices (if any) will be unselected and then the new one will be selected (if possible)

selectVertices

public static void selectVertices(J3DePoint2D p1,
                                  J3DePoint2D p2,
                                  Scene2D scene)
Selects all vertices which are located inside the specified rectangle.

Parameters:
p1 - top left corner of the rectangle
p2 - bottom right corner of the rectangle
scene - Scene2D the selection was made in

isInBounds

public static boolean isInBounds(J3DePoint2D pos,
                                 J3DePoint2D p1,
                                 J3DePoint2D p2)
Returns true if the specified point is located inside the specified rectangle.

Parameters:
pos - the point
p1 - top left corner of the rectangle
p2 - bottom right corner of the rectangle
Returns:
true if the specified point is located inside the specified rectangle

getVertexPosition2D

public static J3DePoint2D getVertexPosition2D(Vertex v,
                                              Scene2D scene)
Returns the position of a vertex in the coordinate system of the specified Scene2D.

Parameters:
v - vertex which coordinates will be returned
scene - Scene2D which coordinate system the specified vertex will be transformed
Returns:
the position of a vertex in the coordinate system of the specified Scene2D

getEdgeEndIndex

public static int getEdgeEndIndex(int vertexIndex,
                                  Scene2D scene)
Returns the index of the second vertex of the edge with the specified first vertex.

Parameters:
vertexIndex - index of the first vertex of this edge
scene - Scene2D which has the reference to that GeometryManipulator in which the vertices are located in
Returns:
the index of the second vertex of the edge with the specified first vertex

translateVertices

public static void translateVertices(float x,
                                     float y,
                                     Scene2D scene)
Translates the selected vertices.

Parameters:
x - change of position on Scene2D X axis
y - change of position on Scene2D Y axis
scene - Scene2D in which the vertices are translated

scaleVertices

public static void scaleVertices(float scaleChange,
                                 Scene2D scene)
Resizes the selected part of a polygonal mesh.

Parameters:
scaleChange - change of scale
scene - Scene2D in which the vertices are scaled

rotateVertices

public static void rotateVertices(float rotation,
                                  Scene2D scene)
Rotates the selected part of a polygonal mesh.

Parameters:
rotation - angle of rotation
scene - Scene2D in which the vertices are rotated

addVertex

public static boolean addVertex(J3DePoint2D location,
                                Scene2D scene)
Adds a new vertex to the specified polygonal mesh if possible.

Parameters:
location - location of vertex in the coordinate system of the specified Scene2D
scene - Scene2D in which the vertex was added
Returns:
true if vertex has been successfully added, otherwise false